package battleship;

import java.util.TreeSet;

/**
 *
 * @author Tomek
 */
public class Rules{
	int xSize, ySize;
	Player player1 = new HumanPlayer(this);
	Player player2;
	boolean corneringAllowed;
	boolean curvedShipsAllowed;
	MyTableModel shipsInGame;
	
	void setSize(int x, int y){
		xSize = x;
		ySize = y;
	}
	void setComputerPlayer(boolean isComputer){
		if(isComputer) player2 = new ComputerPlayer(this);
		else player2 = new HumanPlayer(this);
	}
	void setPlayerNames(String pl1, String pl2){
		player1.setName(pl1);
		player2.setName(pl2);
	}
	void setCorneringAllowed(boolean b){
		corneringAllowed = b;
	}
	void setCurvedShipsAloowed(boolean b){
		curvedShipsAllowed = b;
	}
	@Override
	public String toString(){
		return
						"Player1: "+ player1.getName()+"\n"+
						"Player2: "+ player2.getName()+" "+ (player2 instanceof ComputerPlayer?"Computer":"Human")+"\n"+
						"Size: "+ xSize+"x" +ySize +"\n" +
						shipsInGame;
	}

	boolean checkShip(TreeSet<Field> set) {
		for(Field f: set){
			System.out.println(f);
		}
		return false;
	}

	void setComputerStrategy(ComputerStrategy strategy) {
		((ComputerPlayer)player2).strategy = strategy;
	}
}
